#include "../include/client.h"



int main(int argc,char* argv[])
{
    ARGS_CHECK(argc,3);
    int sockfd = tcp_Init(argv[1],argv[2]);
    
    sendLogin(sockfd);
    fflush(stdin);

    char line[256];

    while(1)
    {
        bzero(line,sizeof(line));
        int ret = read(STDIN_FILENO,line,sizeof(line));
        ERROR_CHECK(ret,-1,"read");
        int sret = send_cmd(line,sockfd);
        if(sret == -1)
        {
            continue;
        }
        train_t train;
        bzero(&train,sizeof(train));
        recv(sockfd,&train.type,sizeof(train.type),MSG_WAITALL);
        recv(sockfd,&train.len,sizeof(train.len),MSG_WAITALL);
        if(train.len == 0)
        {
            continue;
        }
        recv(sockfd,train.data,train.len,MSG_WAITALL);
        printf("response = %s\n",train.data);
    }
    // 下载和上传文件
    /* c_recv_download(sockfd,filename); //把要下载的文件名传进来 */
    /* c_up(sockfd,filename); //把要下载的文件名传进来 */
    return 0;
}

